package array.reverseVowel;

import java.util.HashSet;
/**
 * @Date 2020/04/10
 * @author 王光浩
 * @Thinking 使用双指针
 */
public class MyMethodOne {
	public String reverseVowels(String s) {
		int left=0;
		int right=s.length()-1;
		HashSet<Character> set=new HashSet<Character>();
		char[] ret=s.toCharArray();
		set.add('a');
		set.add('e');
		set.add('i');
		set.add('o');
		set.add('u');
		set.add('A');
		set.add('E');
		set.add('I');
		set.add('O');
		set.add('U');
		while(left<right) {
			while(right>left && !set.contains(ret[left])) left++;
			while(right>left && !set.contains(ret[right]))right--;
			char tem=ret[left];
			ret[left]=ret[right];
			ret[right]=tem;
		}
		return String.valueOf(ret);
    }
}
